LogicalAnd ================= 逐元素执行逻辑与(Logical AND)运算。 对输入张量的对应元素先进行布尔化判断,再执行逻辑与运算,输出结果为 0 或 1, 并以与输入相同的数据类型返回。 .. math:: \text{output}_i = \begin{cases} 1, & \text{if } (\text{input0}_i \neq 0) \land (\text{input1}_i \neq 0) \\ 0, & \text{otherwise} \end{cases} 输入: - **input0** - 第一个输入张量的数据地址。 - **input1** - 第二个输入张量的数据地址。 - **length** - 输入张量的总元素数量。 - **core_mask** - 核掩码。 输出: - **output** - 输出张量的数据地址,其大小与 ``input0``、``input1`` 相同。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - FT78NE 支持的数据类型:fp32, fp64, int8, int16, int32 - MT7004 支持的数据类型:fp16, fp32, int16, int32 - 输入值在参与逻辑运算前会被转换为布尔值(非 0 为 true,0 为 false) - 输出结果仅为 0 或 1 **共享存储版本:** .. c:function:: void fp_and_s(float* input0, float* input1, float* output, int length, int core_mask) .. c:function:: void dp_and_s(double* input0, double* input1, double* output, int length, int core_mask) .. c:function:: void i8_and_s(int8_t* input0, int8_t* input1, int8_t* output, int length, int core_mask) .. c:function:: void i16_and_s(int16_t* input0, int16_t* input1, int16_t* output, int length, int core_mask) .. c:function:: void i32_and_s(int32_t* input0, int32_t* input1, int32_t* output, int length, int core_mask) .. c:function:: void hp_and_s(half* input0, half* input1, half* output, int length, int core_mask) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 13 // FT78NE 多核示例 #include #include int main(int argc, char* argv[]) { float *input0 = (float *)0xA0000000; // input0 在 DDR 空间 float *input1 = (float *)0xA0010000; // input1 在 DDR 空间 float *output = (float *)0xB0000000; // output 在 DDR 空间 int length = 4096; int core_mask = 0xff; fp_and_s(input0, input1, output, length, core_mask); return 0; } **私有存储版本:** .. c:function:: void fp_and_p(float* input0, float* input1, float* output, int length) .. c:function:: void dp_and_p(double* input0, double* input1, double* output, int length) .. c:function:: void i8_and_p(int8_t* input0, int8_t* input1, int8_t* output, int length) .. c:function:: void i16_and_p(int16_t* input0, int16_t* input1, int16_t* output, int length) .. c:function:: void i32_and_p(int32_t* input0, int32_t* input1, int32_t* output, int length) .. c:function:: void hp_and_p(half* input0, half* input1, half* output, int length) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 12 // MT7004 单核示例 #include #include int main(int argc, char* argv[]) { half *input0 = (half *)0x10000000; // input0 在 L2 空间 half *input1 = (half *)0x10002000; // input1 在 L2 空间 half *output = (half *)0x10010000; // output 在 L2 空间 int length = 1024; hp_and_p(input0, input1, output, length); return 0; }